#!/bin/bash

set -e

CURRENT_DIR=$(pwd)
FCGISERVER_ROOT_DIR=$CURRENT_DIR/../bin
NAME=fcgiServer

start_fcgiServer()
{
    cd $FCGISERVER_ROOT_DIR
    sudo ./fcgiServer -d
    cd -
}

shut_fcgiServer()
{
    cd $FCGISERVER_ROOT_DIR
    sudo ./fcgiServer -s
    cd -
}


case "$1" in
  start)
    start_fcgiServer
  ;;
  stop)
    shut_fcgiServer
  ;;
  restart)
    shut_fcgiServer
    start_fcgiServer
  ;;
  *)
    echo "Usage: $NAME {start|stop|restart}" >&2
    exit 2
  ;;
esac
